from tkinter import *
from tkinter import messagebox
import turtle
import random
import requests
import re
import os
import time
import threading
color='aliceblue,antiquewhite,aqua,aquamarine,azure,beige,bisque,black,blanchedalmond,blue,blueviolet,brown,burlywood,' \
      'cadetblue,chartreuse,chocolate,coral,cornflowerblue,cornsilk,crimson,cyan,darkblue,darkcyan,darkgoldenrod,darkgray,' \
      'darkgreen,darkkhaki,darkmagenta,darkolivegreen,darkorange,darkorchid,darkred,darksalmon,darkseagreen,darkslateblue,' \
      'darkslategray,darkturquoise,darkviolet,deeppink,deepskyblue,dimgray,dodgerblue,firebrick,floralwhite,forestgreen,' \
      'fuchsia,gainsboro,ghostwhite,gold,goldenrod,gray,green,greenyellow,honeydew,hotpink,indianred,indigo,ivory,khaki,' \
      'lavender,lavenderblush,lawngreen,lemonchiffon,lightblue,lightcoral,lightcyan,lightgoldenrodyellow,lightgreen,lightgray,' \
      'lightpink,lightsalmon,lightseagreen,lightskyblue,lightslategray,lightsteelblue,lightyellow,lime,limegreen,linen,' \
      'magenta,maroon,mediumaquamarine,mediumblue,mediumorchid,mediumpurple,mediumseagreen,mediumslateblue,mediumspringgreen,' \
      'mediumturquoise,mediumvioletred,midnightblue,mintcream,mistyrose,moccasin,navajowhite,navy,oldlace,olive,olivedrab,' \
      'orange,orangered,orchid,palegoldenrod,palegreen,paleturquoise,palevioletred,papayawhip,peachpuff,peru,pink,plum,powderblue,' \
      'purple,red,rosybrown,royalblue,saddlebrown,salmon,sandybrown,seagreen,seashell,sienna,silver,skyblue,slateblue,' \
      'slategray,snow,springgreen,steelblue,tan,teal,thistle,tomato,turquoise,violet,wheat,white,whitesmoke,yellow,yellowgreen'
listcolor=color.split(',')
chat1=['说别点你还上瘾了？','干一行，爱一行，做一行就要认真','摩托车算是我女朋友吧','人生的赛场，只能一路狂飙','坡顶的景色是下坡',
       '看爸爸对你多么好！','我也是个普通人','我是甜甜，甜过初恋','我可没有涛哥帅','笑琪啊，你可长点心吧','别点了，人家害羞了',
       '我得赶快给我涛哥发个红包']
chat2=['嘤嘤嘤，人家是个女汉子','吓死老娘咧！','别TM点老娘咧！','听不懂人话咋地昂？','别TM逼我抽你！','世上最帅我涛哥！','我是你闺女啊!',
       '今儿个老子生日！','涛哥天下第一帅','我得给涛哥发个红包','SB再点我']
class Application(Frame):
    def __init__(self,master=None,**kw):
        super().__init__(master,**kw)
        self.grid()
        self.num=0
        self.chk=0
        self.tag=[]
        for i in range(5):
            self.tag.append(0)
        self.txt2='不要点我！！！'
        self.master=master
        self.createpage1()
    def createpage1(self):
        # 图片处理
        self.pic1=PhotoImage(file='../image/cake.png')
        self.pic2=PhotoImage(file='../image/username.png')
        self.pic3=PhotoImage(file='../image/passward.png')
        self.pic4 = PhotoImage(file='../image/eyeopen.png')
        self.pic5 = PhotoImage(file='../image/eyeclose.png')
        self.pic6 = PhotoImage(file='../image/qq.png')
        self.pic7 = PhotoImage(file='../image/photo.png')
        lab01=Label(self,image=self.pic1,bg='pink')
        lab01.place(x=70,y=30)
        lab02 = Label(self, image=self.pic2, bg='pink')
        lab02.place(x=750, y=160)
        lab03 = Label(self, image=self.pic3, bg='pink')
        lab03.place(x=750, y=285)
        lab04 = Label(self, image=self.pic4, bg='pink')
        lab04.place(x=100, y=400)
        self.lab05 = Label(self, image=self.pic5, bg='pink')
        self.lab06 = Label(self, image=self.pic6, bg='pink')
        self.lab06.place(x=300, y=400)
        self.lab07 = Label(self, image=self.pic7, bg='pink')
        self.lab07.place(x=500, y=400)
        # 文字处理
        lab02=Label(self,text='Welcome! My Lady！',font=('Comic Sans MS',30),bg='pink')
        lab02.place(x=250,y=55)
        # 文本框处理
        self.v1=StringVar()
        en1=Entry(self,background='pink',textvariable=self.v1,font=('楷体',50),width=18,borderwidth=3,relief='solid')
        en1.place(x=50,y=180)
        self.v2 = StringVar()
        self.en1 = Entry(self,background='pink', textvariable=self.v2, font=('楷体', 50), width=18, borderwidth=3, relief='solid')
        self.en1.place(x=50, y=300)

        # 按键处理
        bt01=Button(self,text='进入喽！->',font=('黑体',30),width=15,borderwidth=5,relief='solid',bg='cyan2',fg='azure',command=self.login)
        bt01.place(x=670,y=415)
        self.lab05.bind('<Button-1>',self.passsee2)
        lab04.bind('<Button-1>', self.passsee1)
        self.lab06.bind('<Button-1>',self.move)
        self.lab07.bind('<Button-1>',self.moveback)
    def createpage2(self):
        self.clearframe()
        self.thread = threading.Thread(target=self.WYB)
        self.thread.start()
        self.pic08=PhotoImage(file='../image/wyb.png')
        self.lab08=Label(self,image=self.pic08,bg='pink')
        self.lab08.bind('<Button-1>',self.ctchange1)
        self.lab08.place(x=100,y=40)
        if self.v1.get()=='李笑琪':
            self.pic09 = PhotoImage(file='../image/lxq.png')
        else:
            self.pic09 = PhotoImage(file='../image/mv.png')
        self.lab09 = Label(self, image=self.pic09, bg='pink')
        self.lab09.bind('<Button-1>',self.ctchange2)
        self.lab09.place(x=600, y=50)
        self.btn02=Button(self,text='点我！点我！快点我！！！',font=('黑体',20),command=self.chick,bg='blue',relief='solid')
        self.btn02.place(x=300,y=400)
        self.piclist=[ 'f'+str(i)+'.png' for i in range(0,22)]
        self.btn03=Button(self,text='点击快速来100下！',bg=random.choice(listcolor),command=self.No,relief='solid',borderwidth=3,font=('黑体，10'))
        self.btn03.place(x=50, y=420)
        self.pic11=PhotoImage(file='../image/chat.png')
        self.pic12 = PhotoImage(file='../image/chat1.png')
        Label(self,image=self.pic11,bg='pink').place(x=280,y=25)
        self.lab10=Label(self,text=self.txt2,font=('楷体',20),bg='pink')
        self.lab10.place(x=295,y=35)
        Label(self,image=self.pic12,bg='pink').place(x=700,y=350)
        self.lab11 = Label(self, text=self.txt2, font=('楷体', 20), bg='pink')
        self.lab11.place(x=705, y=370)
        self.btn04=Button(self,bg='SpringGreen2',command=self.createpage3,relief='solid',font=('黑体',20),text='看这里！下一页->')
    def createpage3(self):
        self.clearframe()
        # image处理
        self.pic13=PhotoImage(file='../image/END.png')
        self.pic14 = PhotoImage(file='../image/gril0.png')
        # Lable处理
        Label(self,image=self.pic13,bg='pink').place(x=100,y=0)
        self.lab12=Label(self,image=self.pic14,bg='pink').place(x=600,y=150)
        Label(self,text='彩蛋你找完了么？？？',bg='aquamarine',font=('楷体',35),fg='hot pink').place(x=70,y=200)
        # Button处理
        Button(self,text='查询',relief='solid',command=self.search,font=('黑体',30),bg='tomato2').place(x=100,y=350)
        self.heart()
    def turtle01(self):
        t = turtle.Turtle()
        turtle.setup(width=1600, height=640, startx=0, starty=0)
        turtle.bgcolor('thistle1')
        t.penup()
        t.speed(0)
        t.pensize(4)
        t.goto(-700, -160)
        t.pendown()
        t.speed(4)
        t.pencolor('turquoise1')
        t.forward(120)
        t.pencolor('Forest Green')
        t.left(75)
        t.forward(80)
        t.right(150)
        t.forward(120)
        t.left(150)
        t.forward(40)
        t.right(75)
        t.pencolor('turquoise1')
        t.forward(20)
        t.pencolor('VioletRed2')
        t.left(55)
        t.forward(30)
        t.right(55)
        t.forward(20)
        t.right(55)
        t.forward(30)
        t.left(55)
        t.pencolor('turquoise1')
        t.forward(30)
        t.pencolor('SeaGreen1')
        t.left(80)
        t.forward(250)
        t.right(160)
        t.forward(320)
        t.left(160)
        t.forward(50)
        t.pencolor('turquoise1')
        t.right(80)
        t.forward(40)
        t.pencolor('aquamarine')
        t.left(80)
        t.forward(70)
        t.right(80)
        t.forward(30)
        t.pencolor('yellow')
        t.right(85)
        t.forward(180)
        t.left(170)
        t.forward(140)
        t.pencolor('turquoise1')
        t.right(85)
        t.forward(100)
        t.pencolor('OrangeRed2')
        t.pensize(6)
        t.left(135)
        t.forward(220)
        t.circle(-130, 180)
        t.forward(40)
        t.left(90)
        t.forward(40)
        t.circle(-130, 180)
        t.forward(220)
        t.left(135)
        t.pencolor('turquoise1')
        t.pensize(4)
        t.forward(100)
        t.pencolor('yellow')
        t.right(85)
        t.forward(140)
        t.left(170)
        t.forward(180)
        t.right(85)
        t.pencolor('aquamarine')
        t.forward(30)
        t.right(80)
        t.forward(70)
        t.left(80)
        t.pencolor('turquoise1')
        t.forward(40)
        t.pencolor('SeaGreen1')
        t.right(80)
        t.forward(50)
        t.left(160)
        t.forward(320)
        t.right(160)
        t.forward(250)
        t.left(80)
        t.pencolor('turquoise1')
        t.forward(30)
        t.pencolor('VioletRed2')
        t.left(55)
        t.forward(30)
        t.right(55)
        t.forward(20)
        t.right(55)
        t.forward(30)
        t.left(55)
        t.pencolor('turquoise1')
        t.forward(20)
        t.right(75)
        t.pencolor('Forest Green')
        t.forward(40)
        t.left(150)
        t.forward(120)
        t.right(150)
        t.forward(80)
        t.pencolor('turquoise1')
        t.left(75)
        t.forward(120)
        time.sleep(3)
        t.clear()
        t.penup()
        t.goto(-300,0)
        t.pendown()
        t.write('不要关闭这个页面哦！\n请从任务栏返回到主程序中',font=('Arial', 50, 'bold'))
        time.sleep(5)
        t.clear()
    def login(self):
        self.num+=1
        if (self.v1.get()=='李笑琪'or self.v1.get()=='admin') and (self.v2.get()=='20200420'or self.v2.get()=='159357'):
            messagebox.showinfo(title='我的傻闺女，爸爸爱你',message='猜了'+str(self.num)+'次才猜对，真够蠢的。。。')
            self.createpage2()
            self.turtle01()

        elif (self.v1.get()=='李笑琪'or self.v1.get()=='admin')and (self.v2.get()!='20200420'or self.v2.get()=='159357'):
            if self.num<3:
                messagebox.showinfo(title='我的傻闺女，爸爸爱你',message='光记得你名字啊，你生日嘞？')
            else:
                messagebox.showinfo(title='我的傻闺女，爸爸爱你',message='我服了，你去看看今天几号。')
        elif (self.v1.get()!='李笑琪'or self.v1.get()=='admin') and (self.v2.get()=='20200420'or self.v2.get()=='159357'):
            messagebox.showinfo(title='我的傻闺女，爸爸爱你',message='你不知道你叫啥？？？')
        else:
            messagebox.showinfo(title='我的傻闺女，爸爸爱你',message='给你个提示，第一个你名字...')
            messagebox.showinfo(title='我的傻闺女，爸爸爱你',message='赶紧医院测智商去吧......')
    def clearframe(self):
        for widget in Application.winfo_children(self):
            widget.destroy()
    def heart(self):
        t=turtle.Turtle()
        turtle.setup(width=1600, height=640, startx=0, starty=0)
        turtle.bgcolor('thistle1')
        for i in range(100):
            t.penup()
            t.goto(x=random.randint(-700, 700), y=random.randint(-300, 300))
            clo = random.choice(listcolor)
            t.pendown()
            t.pencolor(clo)
            t.pensize(4)
            t.speed(0)
            angle = random.randint(-25, 25)
            size = random.randint(20, 100)
            t.left(angle=angle)
            t.begin_fill()
            t.color(clo)
            t.left(135)
            t.forward(size)
            t.circle(-size / 2, 180)
            t.left(90)
            t.circle(-size / 2, 180)
            t.forward(size)
            t.left(135)
            t.end_fill()
            t.right(angle=angle)
        t.penup()
        t.goto(x=-250, y=150)
        t.pendown()
        t.pencolor('dark slate gray')
        t.write('生日快乐啊！！！', font=('Arial', 50, 'bold'))
        turtle.done()
    def passsee1(self,e):
        self.lab05.place(x=100, y=400)
        self.en1['show']='*'
        self.tag[0]=1
    def passsee2(self,e):
        self.lab05.place(x=1000, y=4000)
        self.en1['show'] = 'Z'
    def move(self,e):
        self.lab06.place(x=random.randint(1,900), y=random.randint(1,400))
    def moveback(self, e):
        self.lab06.place(x=300, y=400)
        self.tag[1]=1
    def WYB(self):
        head = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36'}
        url1 = requests.get('http://www.win4000.com/mt/wangyibo_1.html', headers=head).text
        list1 = re.findall('<a target="_blank" href="(.*?)">', url1)

        for urls1 in list1:
            respond = requests.get(urls1, headers=head)
            url2 = respond.text
            dirname = ''.join(re.findall('<title>(.*?)_明星_美桌网</title>', url2))
            list02 = re.findall('data-original="(.*?)_130_170.jpg" alt="王一博', url2)
            try:
                os.makedirs('D:\WYB\\' + dirname + '1')
                for pics in list02:
                    pcs1 = pics + '.jpg'
                    filename = pcs1.split('/')[-1]
                    respond = requests.get(pcs1, headers=head)
                    with open(file='D:\WYB\\' + dirname + '1\\' + filename, mode='wb') as f:
                        f.write(respond.content)
            except BaseException as e:
                print(e)


    def chick(self):

        self.chk+=1
        self.btn02['bg']=random.choice(listcolor)
        if self.chk<100:
            txt1='点击520下有惊喜哦！'
        elif self.chk>=100 and self.chk<200:
            txt1='你手速好慢啊，菜狗！'
        elif self.chk>=200 and self.chk<520:
            txt1='闺女！加油！！！！！'
        else:
            txt1='找完彩蛋才有惊喜哦~~~~~'
            self.btn04.place(x=750, y=450)


        Label(self,text=txt1,font=('楷体',25),bg='cyan',fg=random.choice(listcolor)).place(x=300,y=100)
        Label(self,text=self.chk,font=('黑体',60),relief='solid',bg='pink',borderwidth=3).place(x=420,y=150)
        self.pic10 = PhotoImage(file='../image/'+random.choice(self.piclist))
        Label(self,image=self.pic10,bg='pink').place(x=415,y=250)
        self.btn03['bg']=random.choice(listcolor)
    def No(self):
        messagebox.showinfo(title='傻东西',message='别白想了，不可能给你开小灶的，作为惩罚，就给你清空掉吧...')
        self.chk=0
        self.tag[4]=1
    def ctchange1(self,e):
        self.lab10['text']=random.choice(chat1)
        self.tag[2]=1
    def ctchange2(self,e):
        self.lab11['text']=random.choice(chat2)
        self.tag[3]=1
    def search(self):
        for i in range(5):
             if self.tag[i]==0:
                if i==0:
                    messagebox.showinfo(message='软件登陆页面那小眼睛干啥用的？')
                elif i == 1:
                    messagebox.showinfo(message='你看软件登陆页面难道还有QQ登陆和手机登陆方式？')
                elif i == 2:
                    messagebox.showinfo(message='王一博不让你点他你就不点了啊！')
                elif i == 3:
                    messagebox.showinfo(message='你点你点你那大脸！')
                else :
                    messagebox.showinfo(message='快速加100下！爽！！！！')
        if self.tag.count(0)!=0:
            messagebox.showinfo(message='你还有'+str(self.tag.count(0))+'个彩蛋没找出来呦~~~~')
        else:
            messagebox.showinfo(message='你居然把彩蛋找完了.....')
            messagebox.showinfo(message='写这玩意儿累死爸爸了.....')
            messagebox.showinfo(message='行了，去你D盘找WYB文件夹吧~~~~')
            messagebox.showinfo(message='你D盘已经有WYB了！')
            messagebox.showinfo(message='想重新下载先删除WYB那个文件夹')

root=Tk()
root.title('无郁出品，私人定制！')
root.geometry('1000x500+100+100')
app=Application(root,background='pink',width=1000,height=500)
root.resizable(0,0)
root.mainloop()
